package com.neusoft.resturant.controller;


import com.neusoft.resturant.entity.ResDishes;
import com.neusoft.resturant.entity.ResOrderdetails;
import com.neusoft.resturant.service.IResOrderdetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 订单Controller
 * 
 * @author ruoyi
 * @date 2023-12-10
 */
@RestController
@RequestMapping("/restaurant/orderdetails")
public class ResOrderdetailsController extends BaseController
{
    @Autowired
    private IResOrderdetailsService resOrderdetailsService;




    /**
     * 获取订单详细信息
     */
    @GetMapping("/{id}")
    public ResOrderdetails getInfo(@PathVariable(value = "id") Long resOrderdetailsId) {
        System.out.println("id=" + resOrderdetailsId);
        ResOrderdetails orderdetails = resOrderdetailsService.selectResOrderdetailsById(resOrderdetailsId);
        return orderdetails;
    }

    /**
     * 新增订单
     */
    @PostMapping("/add")
    public int add(@RequestBody ResOrderdetails resOrderdetails)
    {


        System.out.println("新增成功");
        return (resOrderdetailsService.insertResOrderdetails(resOrderdetails));
    }

    /**
     * 修改订单
     */
    @PutMapping("/edit")
    public int edit(@RequestBody ResOrderdetails resOrderdetails) {
        System.out.println("修改成功");
        return (resOrderdetailsService.updateResOrderdetails(resOrderdetails));
    }

        /**
         * 删除订单
         */
        @DeleteMapping("/remove/{id}")
        public int remove(@PathVariable Long[] id)
        {
            return (resOrderdetailsService.deleteResOrderdetailsByIds(id));
        }

    }
